// StockBar.h : Declaration of the CStockBar

#pragma once

#include "ButtonKlass_i.h"
#include "ReflectionWnd.h"

/**
 * Implementation of IDeskBand.
 */
class ATL_NO_VTABLE CStockBar
	: public CComObjectRootEx<CComSingleThreadModel>
	, public CComCoClass<CStockBar, &CLSID_StockBar>
	, public IObjectWithSiteImpl<CStockBar>
	, public IDeskBand
	, public IDispatchImpl<IStockBar, &IID_IStockBar, &LIBID_ButtonKlassLib, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
public:
	CStockBar();
	~CStockBar();

DECLARE_REGISTRY_RESOURCEID(IDR_STOCKBAR)

DECLARE_NOT_AGGREGATABLE(CStockBar)

BEGIN_COM_MAP(CStockBar)
	COM_INTERFACE_ENTRY(IStockBar)
	COM_INTERFACE_ENTRY(IDispatch)
	COM_INTERFACE_ENTRY(IOleWindow)
	COM_INTERFACE_ENTRY(IObjectWithSite)
	COM_INTERFACE_ENTRY_IID(IID_IDeskBand, IDeskBand)
	COM_INTERFACE_ENTRY_IID(IID_IDockingWindow, IDockingWindow)
END_COM_MAP()

	DECLARE_PROTECT_FINAL_CONSTRUCT()

	HRESULT FinalConstruct()
	{
		return S_OK;
	}

	void FinalRelease()
	{
	}

// IDeskBand
public:
	STDMETHOD(GetBandInfo)(DWORD dwBandID, DWORD dwViewMode, DESKBANDINFO* pdbi);

// IObjectWithSite
public:
	STDMETHOD(SetSite)(IUnknown* pUnkSite);

// IOleWindow
public:
	STDMETHOD(GetWindow)(HWND* phwnd);
	STDMETHOD(ContextSensitiveHelp)(BOOL fEnterMode);

// IDockingWindow
public:
	STDMETHOD(CloseDW)(unsigned long dwReserved);
	STDMETHOD(ResizeBorderDW)(const RECT* prcBorder, IUnknown* punkToolbarSite, BOOL fReserved);
	STDMETHOD(ShowDW)(BOOL fShow);

// IStockBar
public:
	void FocusChange(BOOL bHaveFocus);

// DWebBrowserEvents2
public:
	STDMETHOD(DocumentComplete)(IDispatch* pDisp, VARIANT* URL);

protected:
	// Creates reflect window and toolbar 
	BOOL RegisterAndCreateWindow();

	void UnsetSite();

protected:
	WEBBrowser					m_browser;
	CComPtr<IInputObjectSite>	m_pSite;
	DWORD						m_dwCookie;

	DWORD m_dwBandID;
	DWORD m_dwViewMode;

	BOOL m_bShow;
	BOOL m_bEnterHelpMode;

	CWindow			m_wndParent;
	CReflectionWnd	m_ReflectWnd;

 	__declspec(property(get = GetToolbar)) CKlassToolbar Toolbar;
 	CKlassToolbar& GetToolbar()
 	{
 		return m_ReflectWnd.GetToolBar();
 	}

    void CheckForUpdate();

private:
	static CLogger logger;
};

OBJECT_ENTRY_AUTO(__uuidof(StockBar), CStockBar)
